<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%
        request.setAttribute("APP_PATH", request.getContextPath());
    %>
    <script src="${APP_PATH}/static/jquery.min.js"></script>
    <script src="${APP_PATH}/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="${APP_PATH}/static/bootstrap-3.3.7-dist/css/bootstrap.min.css">
</head>
<body>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改成绩</h4>
            </div>
            <div class="modal-body">
                <div class="modal-body">
                    <form class="form-horizontal" method="post">
                        <div>
                            <div class="form-group">
                                <label for="sId" class="col-sm-2 control-label">学生编号</label>
                                <div class="col-sm-10">
                                    <input type="text" name="sId" class="form-control" id="sId" placeholder="学生编号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="cId" class="col-sm-2 control-label">课程编号</label>
                                <div class="col-sm-10">
                                    <input type="text" name="cId" class="form-control" id="cId" placeholder="1-软;2-网;3-数据库;4-L;5-操;6-W;7-数8-Java">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="grade" class="col-sm-2 control-label">学生成绩</label>
                                <div class="col-sm-10">
                                    <input type="text" name="grade" class="form-control" id="grade" placeholder="学生成绩">
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="update">修改</button>
                <button type="button" class="btn btn-primary" id="cancle">取消</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除成绩</h4>
            </div>
                <div class="modal-body">
                    <form class="form-horizontal" method="post">
                        <div>
                            <div class="form-group">
                                <label for="sId" class="col-sm-2 control-label">学生编号</label>
                                <div class="col-sm-10">
                                    <input type="text" name="sId" class="form-control" id="sId1" placeholder="学生编号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="cId" class="col-sm-2 control-label">课程编号</label>
                                <div class="col-sm-10">
                                    <input type="text" name="cId" class="form-control" id="cId1" placeholder="1-软;2-网;3-数据库;4-L;5-操;6-W;7-数8-Java">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="grade" class="col-sm-2 control-label">学生成绩</label>
                                <div class="col-sm-10">
                                    <input type="text" name="grade" class="form-control" id="grade1" placeholder="学生成绩">
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="delete">确认删除</button>
                <button type="button" class="btn btn-primary" id="cancle1">取消</button>
            </div>
        </div>
    </div>
</div>
<%--主体--%>
<div class="container">
    <%--标题--%>
    <div class="row">
        <div class="col-md-12">
            <img src="${APP_PATH}/static/image/head730.jpg">
        </div>
    </div>
    <%--显示数据--%>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover" id="emps_a_table">
                <tr>
                    <th>#</th>
                    <th>name</th>
                    <th>课程名</th>
                    <th>课程成绩</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${courses}" var="course">
                <tr>
                    <td>${course.id}</td>
                    <td>${course.SName}</td>
                    <td>${course.CName}</td>
                    <td>${course.grade}</td>
                    <td>
                        <button class="btn btn-warning update">修改</button>
                        <button class="btn btn-danger delete">删除</button>
                    </td>
                </tr>
                </c:forEach>
            </table>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.update').click(function () {
            $('#myModal').modal({
                backdrop:'static'
            })
        })

        $('.delete').click(function () {
            $('#myModal1').modal({
                backdrop:'static'
            })
        })

        $('#delete').click(function () {
            $.ajax({
                url:'${APP_PATH}/admin/deleteReport',
                type:'post',
                data:$('#myModal1 form').serialize(),
                success:function (data) {
                }
            })
        })

        $('#update').click(function () {
            $.ajax({
                url:'${APP_PATH}/admin/updateReport',
                type:'post',
                data:$('#myModal form').serialize(),
                success:function (data) {
                }
            })
        })
    })
</script>
</body>
</html>
